//
//  FileUtils.m
//  RTCClient
//
//  Created by rykeryin on 2021/9/7.
//

#import "FileUtils.h"
#import <stdio.h>

static FILE *fd = NULL;

@implementation FileUtils

+ (void)appendDocumentsFile:(NSString *)path buffer:(char *)buffer size:(size_t)size {
    if (!fd) {
        fd = fopen([[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:path].UTF8String, "w");
    }
    size_t w_size1 = fwrite("\x01\x00\x00\x00\x01\x00\x00\x00\x01", 9, 1, fd);
    if (w_size1 <= 0) {
        printf("写入数据失败: %s", path.UTF8String);
    }
    size_t w_size2 = fwrite(buffer, size, 1, fd);
    if (w_size2 <= 0) {
        printf("写入数据失败: %s", path.UTF8String);
    }
}

@end
